package com.gscitysfy.cus.drain.modules.duty.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gscitysfy.cus.drain.modules.duty.entity.MoperDutyMnRota;
import com.gscitysfy.cus.drain.modules.duty.mapper.MoperDutyMnRotaMapper;
import com.gscitysfy.cus.drain.modules.duty.service.IMoperDutyMnRotaService;
import com.gscitysfy.cus.drain.utils.DateUtil;
import org.apache.http.util.Asserts;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Administrator
 * @since 2022-03-29 15:06:16
 */
@Service
public class MoperDutyMnRotaServiceImpl extends ServiceImpl<MoperDutyMnRotaMapper, MoperDutyMnRota> implements IMoperDutyMnRotaService {

    @Override
    public void removeAllCurrentMonthGenerateDate(Date planDate) {
        Asserts.notNull(planDate, "planDate不可为null");
        Date beginDate = DateUtil.getMonthBeginDate(planDate);
        Date endDate = DateUtil.getMonthEndDate(planDate);
        remove(
                Wrappers.<MoperDutyMnRota>lambdaQuery()
                        .ge(MoperDutyMnRota::getCoamGenerateDate, beginDate)
                        .le(MoperDutyMnRota::getCoamGenerateDate, endDate)
        );
    }
}
